package raytracer.math;

/**
 * 
 * @author Thorsten Roth
 * @version 11.10.2006
 */
public class Tuple3d {
	
	public double x,y,z;
	
	public Tuple3d(double x,double y,double z) {
		this.x=x;
		this.y=y;
		this.z=z;
	}
	
	public Tuple3d(Tuple3d t3d) {
		this(t3d.x,t3d.y,t3d.z);
	}
	
	public Tuple3d() {
		this(0,0,0);
	}
	
	public double getSum() {
		return this.x+this.y+this.z;
	}
	
	public void set(double x,double y,double z) {
		this.x=x;
		this.y=y;
		this.z=z;
	}
	
	public void set(Tuple3d t3d) {
		this.x=t3d.x;
		this.y=t3d.y;
		this.z=t3d.z;
	}
	
	public void scale(Tuple3d t) {
		scale(t.x,t.y,t.z);
	}
	
	public void scale(double f) {
		scale(f,f,f);
	}
	
	public void scale(double xf,double yf,double zf) {
		x*=xf;
		y*=yf;
		z*=zf;
	}
	
	public void negate() {
		x=-x;
		y=-y;
		z=-z;
	}
	
	public void add(Tuple3d t3d) {
		x+=t3d.x;
		y+=t3d.y;
		z+=t3d.z;
	}
	
	public void sub(Tuple3d t3d) {
		x-=t3d.x;
		y-=t3d.y;
		z-=t3d.z;
	}
		
	public String toString() {
		return ("("+this.x+", "+this.y+", "+this.z+")");
	}
	
}
